//
//  YYJLNewShopDetailController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/6.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLNewShopDetailController.h"
#import "ShowPictureView.h"
@interface YYJLNewShopDetailController ()<UIScrollViewDelegate>
{
    UIScrollView * _scrollview;
    UILabel * currentLb;//图片滚动显示
    UILabel * contentLb;//内容
    NSMutableArray * picArr;//图片数组
}
@end

@implementation YYJLNewShopDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
     picArr=[[NSMutableArray alloc]initWithObjects:@"img_xinpin1",@"img_xinpin2",@"img_xinpin1", nil];
    [self setTitleView:@"新店详情"];
    [self setBackItem];
    [self creatUI];
    
}

-(void)creatUI{
    
    //文字区域
    UIView * contentView =[[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-100*PER_HEIGHT, SCREEN_WIDTH, 100*PER_HEIGHT)];
    contentView.backgroundColor=[UIColorFromHex(0x000000) colorWithAlphaComponent:.4];
    [self.view addSubview:contentView];
    currentLb=[MyControl createLabelWithFrame:CGRectMake(15*PER_WIDTH, 15*PER_HEIGHT, 100, 18*PER_HEIGHT) Font:18 Text:@"1/3" Color:WHITE_COLOR];
    currentLb.font=[UIFont fontWithName:HLT size:18*PER_HEIGHT];
    [contentView addSubview:currentLb];
    
    contentLb=[MyControl createLabelWithFrame:CGRectMake(currentLb.left, currentLb.bottom+14*PER_HEIGHT, contentView.width-30*PER_WIDTH, contentView.height-47*PER_HEIGHT) Font:15 Text:@"车公庙店" Color:WHITE_COLOR];
    contentLb.numberOfLines=0;
    [contentView addSubview:contentLb];
    //滑动区域
    _scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, contentView.top-25*PER_HEIGHT)];
    _scrollview.delegate=self;
    _scrollview.pagingEnabled=YES;
    _scrollview.contentSize=CGSizeMake(SCREEN_WIDTH*picArr.count, 0);
    [self.view addSubview:_scrollview];
    
    for (int i=0; i<picArr.count; i++) {
        UIImageView * picShow=[[UIImageView alloc]initWithFrame:CGRectMake(0+i*SCREEN_WIDTH, 0, _scrollview.width, _scrollview.height)];
        picShow.image=[UIImage imageNamed:picArr[i]];
        [_scrollview addSubview:picShow];
        UITapGestureRecognizer * tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click:)];
        picShow.userInteractionEnabled=YES;
        picShow.tag=i;
        [picShow addGestureRecognizer:tap];
    }


}
#pragma mark--点击图片放大
-(void)click:(UIGestureRecognizer*)tap{
    ShowPictureView *show = [[ShowPictureView alloc]initWithDataArr:picArr withMark:tap.view.tag];
    show.orientation = self.orientation;
    
    [show onShowInWindow];
}
#pragma mark--scrollview
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    NSInteger index = _scrollview.contentOffset.x / _scrollview.width;
    
    currentLb.text=[NSString stringWithFormat:@"%ld / %lu",index+1,(unsigned long)picArr.count];
    contentLb.text= [NSString stringWithFormat:@"%@ +%ld",@"沃达",(long)index];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
